package getYaml;

import org.yaml.snakeyaml.Yaml;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.net.URL;
import java.util.Map;

public class Main {
    public static void main(String[] args) throws FileNotFoundException {
        //路径测试,class.getResource("/") == class.getClassLoader().getResource("")
//        System.out.println(Main.class.getResource("person.yml"));
//        System.out.println(Main.class.getResource("/person.yml"));
//        System.out.println("===============");
//        System.out.println(Main.class.getClassLoader().getResource("person.yml"));
//        System.out.println(Main.class.getClassLoader().getResource("/person.yml"));
        //读取yaml
        URL url = Main.class.getResource("/person.yml");
        FileInputStream fileInputStream = new FileInputStream(url.getFile());
        Yaml yaml = new Yaml();
        Map load = (Map) yaml.load(fileInputStream);
        System.out.println(load);
    }
}
